﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;


namespace FYPDemo
{
    public partial class WebForm9 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                string loginUser = Session["username"].ToString();
                string profileOwner = "";
                
                ViewState["profileOwner"] = Request.QueryString["username2"];

                if (ViewState["profileOwner"] != null)
                    profileOwner = ViewState["profileOwner"].ToString();
                else
                    profileOwner = loginUser;
                
                int role = Convert.ToInt32(Session["Role"]);

                DataTable dt = Member.showMemberDetails(profileOwner);

                if (dt.Rows.Count > 0)
                {
                    lblCompany.Text = "[" + dt.Rows[0][1].ToString() + "]";
                    lblDateJoined.Text = dt.Rows[0][3].ToString();
                    partnerImg.ImageUrl = dt.Rows[0][12].ToString();
                    lblAddress.Text = dt.Rows[0][6].ToString();
                    lblEmailAdd.Text = dt.Rows[0][5].ToString();
                    lblPhoneNum.Text = dt.Rows[0][10].ToString();
                    lblPoint.Text = dt.Rows[0][11].ToString();

                    int TempRole = Convert.ToInt32(dt.Rows[0][9].ToString());

                    if (TempRole == 1)
                    {
                        lblStatus.Text = "Administrator";
                    }
                    else if (TempRole == 2)
                    {
                        lblStatus.Text = "Member";
                        memberReportDIV.Style.Add("display", "block");
                        
                    }
                    else
                    {
                        lblStatus.Text = "Vendor";
                        vendorReportDIV.Style.Add("display", "block");
                    }
                }

                if (profileOwner == loginUser)
                {
                    btnEdit.Enabled = true;

                    if (role == 2)
                    {
                        memberReportDIV.Style.Add("display", "block");
                    }

                    if (role == 3)
                    {
                        btnProducts.Enabled = true;
                        vendorReportDIV.Style.Add("display", "block");
                    }
                }

                
            }
        }

        protected void btnEdit_Click(object sender, EventArgs e)
        {
            Response.Redirect("ProfileMaintenance.aspx");
        }      
    }
}